package com.fjwt.gz.mch.ctrl.Temporary;

import com.alibaba.fastjson2.JSONObject;
import com.fjwt.gz.core.model.ApiRes;
import com.fjwt.gz.core.utils.SpringBeansUtil;
import com.fjwt.gz.db.dto.FansActivityDTO;
import com.fjwt.gz.mch.ctrl.CommonCtrl;
import com.fjwt.gz.service.activity.BaseActivityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
@RequestMapping("/api/temporaryNew")
public class TemporaryNew extends CommonCtrl {


    /**
     * 兑换奖品
     */
    @PostMapping("/activities")
    public ApiRes gtProcess() {
        JSONObject json = getObject(JSONObject.class);
        Long fansId=getCurrentUser().getFansId();
        String appid = request.getHeader("appid");
        Long activityId = json.getLong("activityId");
        Long awardId = json.getLong("awardId");
        Integer awardType = json.getInteger("awardType");
        BaseActivityService activityService = SpringBeansUtil.getBean("ACTE026" + "Service", BaseActivityService.class);
        FansActivityDTO fansActivityDTO = new FansActivityDTO();
        fansActivityDTO.setActivityId(activityId);
        fansActivityDTO.setAwardId(awardId);
        fansActivityDTO.setFansId(fansId);
        fansActivityDTO.setAppId(appid);
        fansActivityDTO.setJoinType(awardType);
        activityService.takePartIn(fansActivityDTO);
        return ApiRes.ok();
    }

}
